package chapter2.No2_2_synchronized同步语句块.g将任意对象作为对象监视器.demo1;

/**
 * Created by Administrator on 2016/11/12.
 */
public class ServiceClass {
    String anyObject = new String();

    public void methodA() {

        synchronized (anyObject) {
            try {
                System.out.println("线程"+Thread.currentThread().getName()+" begin methodA");
                Thread.sleep(1500);
                System.out.println("线程"+Thread.currentThread().getName()+" end methodA");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
